using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Commerce.Common
{
	/// <summary>
	/// Strongly-typed collection for the OrderItem class.
	/// </summary>
	[Serializable]
	public partial class OrderItemCollection : ActiveList<OrderItem,OrderItemCollection> 
	{	   
		public OrderItemCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the CSK_Store_OrderItem table.
	/// </summary>
	[Serializable]
	public partial class OrderItem : ActiveRecord<OrderItem>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public OrderItem()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public OrderItem(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

        
		public OrderItem(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public OrderItem(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }

		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		public static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("CSK_Store_OrderItem", TableType.Table, DataService.GetInstance("dashCommerce"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarOrderItemID = new TableSchema.TableColumn(schema);
				colvarOrderItemID.ColumnName = "orderItemID";
				colvarOrderItemID.DataType = DbType.Int32;
				colvarOrderItemID.MaxLength = 0;
				colvarOrderItemID.AutoIncrement = true;
				colvarOrderItemID.IsNullable = false;
				colvarOrderItemID.IsPrimaryKey = true;
				colvarOrderItemID.IsForeignKey = false;
				colvarOrderItemID.IsReadOnly = false;
				colvarOrderItemID.DefaultSetting = @"";
				colvarOrderItemID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOrderItemID);
				
				TableSchema.TableColumn colvarOrderID = new TableSchema.TableColumn(schema);
				colvarOrderID.ColumnName = "orderID";
				colvarOrderID.DataType = DbType.Int32;
				colvarOrderID.MaxLength = 0;
				colvarOrderID.AutoIncrement = false;
				colvarOrderID.IsNullable = false;
				colvarOrderID.IsPrimaryKey = false;
				colvarOrderID.IsForeignKey = true;
				colvarOrderID.IsReadOnly = false;
				colvarOrderID.DefaultSetting = @"";
				
					colvarOrderID.ForeignKeyTableName = "CSK_Store_Order";
				schema.Columns.Add(colvarOrderID);
				
				TableSchema.TableColumn colvarProductID = new TableSchema.TableColumn(schema);
				colvarProductID.ColumnName = "productID";
				colvarProductID.DataType = DbType.Int32;
				colvarProductID.MaxLength = 0;
				colvarProductID.AutoIncrement = false;
				colvarProductID.IsNullable = false;
				colvarProductID.IsPrimaryKey = false;
				colvarProductID.IsForeignKey = false;
				colvarProductID.IsReadOnly = false;
				colvarProductID.DefaultSetting = @"";
				colvarProductID.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProductID);
				
				TableSchema.TableColumn colvarSku = new TableSchema.TableColumn(schema);
				colvarSku.ColumnName = "sku";
				colvarSku.DataType = DbType.String;
				colvarSku.MaxLength = 50;
				colvarSku.AutoIncrement = false;
				colvarSku.IsNullable = true;
				colvarSku.IsPrimaryKey = false;
				colvarSku.IsForeignKey = false;
				colvarSku.IsReadOnly = false;
				colvarSku.DefaultSetting = @"";
				colvarSku.ForeignKeyTableName = "";
				schema.Columns.Add(colvarSku);
				
				TableSchema.TableColumn colvarProductName = new TableSchema.TableColumn(schema);
				colvarProductName.ColumnName = "productName";
				colvarProductName.DataType = DbType.String;
				colvarProductName.MaxLength = 250;
				colvarProductName.AutoIncrement = false;
				colvarProductName.IsNullable = true;
				colvarProductName.IsPrimaryKey = false;
				colvarProductName.IsForeignKey = false;
				colvarProductName.IsReadOnly = false;
				colvarProductName.DefaultSetting = @"";
				colvarProductName.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProductName);
				
				TableSchema.TableColumn colvarImageFile = new TableSchema.TableColumn(schema);
				colvarImageFile.ColumnName = "imageFile";
				colvarImageFile.DataType = DbType.String;
				colvarImageFile.MaxLength = 500;
				colvarImageFile.AutoIncrement = false;
				colvarImageFile.IsNullable = true;
				colvarImageFile.IsPrimaryKey = false;
				colvarImageFile.IsForeignKey = false;
				colvarImageFile.IsReadOnly = false;
				colvarImageFile.DefaultSetting = @"";
				colvarImageFile.ForeignKeyTableName = "";
				schema.Columns.Add(colvarImageFile);
				
				TableSchema.TableColumn colvarProductDescription = new TableSchema.TableColumn(schema);
				colvarProductDescription.ColumnName = "productDescription";
				colvarProductDescription.DataType = DbType.String;
				colvarProductDescription.MaxLength = 2500;
				colvarProductDescription.AutoIncrement = false;
				colvarProductDescription.IsNullable = true;
				colvarProductDescription.IsPrimaryKey = false;
				colvarProductDescription.IsForeignKey = false;
				colvarProductDescription.IsReadOnly = false;
				colvarProductDescription.DefaultSetting = @"";
				colvarProductDescription.ForeignKeyTableName = "";
				schema.Columns.Add(colvarProductDescription);
				
				TableSchema.TableColumn colvarPromoCode = new TableSchema.TableColumn(schema);
				colvarPromoCode.ColumnName = "promoCode";
				colvarPromoCode.DataType = DbType.String;
				colvarPromoCode.MaxLength = 50;
				colvarPromoCode.AutoIncrement = false;
				colvarPromoCode.IsNullable = true;
				colvarPromoCode.IsPrimaryKey = false;
				colvarPromoCode.IsForeignKey = false;
				colvarPromoCode.IsReadOnly = false;
				colvarPromoCode.DefaultSetting = @"";
				colvarPromoCode.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPromoCode);
				
				TableSchema.TableColumn colvarWeight = new TableSchema.TableColumn(schema);
				colvarWeight.ColumnName = "weight";
				colvarWeight.DataType = DbType.Currency;
				colvarWeight.MaxLength = 0;
				colvarWeight.AutoIncrement = false;
				colvarWeight.IsNullable = true;
				colvarWeight.IsPrimaryKey = false;
				colvarWeight.IsForeignKey = false;
				colvarWeight.IsReadOnly = false;
				colvarWeight.DefaultSetting = @"";
				colvarWeight.ForeignKeyTableName = "";
				schema.Columns.Add(colvarWeight);
				
				TableSchema.TableColumn colvarDimensions = new TableSchema.TableColumn(schema);
				colvarDimensions.ColumnName = "dimensions";
				colvarDimensions.DataType = DbType.String;
				colvarDimensions.MaxLength = 50;
				colvarDimensions.AutoIncrement = false;
				colvarDimensions.IsNullable = true;
				colvarDimensions.IsPrimaryKey = false;
				colvarDimensions.IsForeignKey = false;
				colvarDimensions.IsReadOnly = false;
				colvarDimensions.DefaultSetting = @"";
				colvarDimensions.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDimensions);
				
				TableSchema.TableColumn colvarLength = new TableSchema.TableColumn(schema);
				colvarLength.ColumnName = "length";
				colvarLength.DataType = DbType.Decimal;
				colvarLength.MaxLength = 0;
				colvarLength.AutoIncrement = false;
				colvarLength.IsNullable = false;
				colvarLength.IsPrimaryKey = false;
				colvarLength.IsForeignKey = false;
				colvarLength.IsReadOnly = false;
				colvarLength.DefaultSetting = @"";
				colvarLength.ForeignKeyTableName = "";
				schema.Columns.Add(colvarLength);
				
				TableSchema.TableColumn colvarHeight = new TableSchema.TableColumn(schema);
				colvarHeight.ColumnName = "height";
				colvarHeight.DataType = DbType.Decimal;
				colvarHeight.MaxLength = 0;
				colvarHeight.AutoIncrement = false;
				colvarHeight.IsNullable = false;
				colvarHeight.IsPrimaryKey = false;
				colvarHeight.IsForeignKey = false;
				colvarHeight.IsReadOnly = false;
				colvarHeight.DefaultSetting = @"";
				colvarHeight.ForeignKeyTableName = "";
				schema.Columns.Add(colvarHeight);
				
				TableSchema.TableColumn colvarWidth = new TableSchema.TableColumn(schema);
				colvarWidth.ColumnName = "width";
				colvarWidth.DataType = DbType.Decimal;
				colvarWidth.MaxLength = 0;
				colvarWidth.AutoIncrement = false;
				colvarWidth.IsNullable = false;
				colvarWidth.IsPrimaryKey = false;
				colvarWidth.IsForeignKey = false;
				colvarWidth.IsReadOnly = false;
				colvarWidth.DefaultSetting = @"";
				colvarWidth.ForeignKeyTableName = "";
				schema.Columns.Add(colvarWidth);
				
				TableSchema.TableColumn colvarDimensionUnit = new TableSchema.TableColumn(schema);
				colvarDimensionUnit.ColumnName = "dimensionUnit";
				colvarDimensionUnit.DataType = DbType.String;
				colvarDimensionUnit.MaxLength = 20;
				colvarDimensionUnit.AutoIncrement = false;
				colvarDimensionUnit.IsNullable = false;
				colvarDimensionUnit.IsPrimaryKey = false;
				colvarDimensionUnit.IsForeignKey = false;
				colvarDimensionUnit.IsReadOnly = false;
				colvarDimensionUnit.DefaultSetting = @"";
				colvarDimensionUnit.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDimensionUnit);
				
				TableSchema.TableColumn colvarQuantity = new TableSchema.TableColumn(schema);
				colvarQuantity.ColumnName = "quantity";
				colvarQuantity.DataType = DbType.Int32;
				colvarQuantity.MaxLength = 0;
				colvarQuantity.AutoIncrement = false;
				colvarQuantity.IsNullable = false;
				colvarQuantity.IsPrimaryKey = false;
				colvarQuantity.IsForeignKey = false;
				colvarQuantity.IsReadOnly = false;
				colvarQuantity.DefaultSetting = @"";
				colvarQuantity.ForeignKeyTableName = "";
				schema.Columns.Add(colvarQuantity);
				
				TableSchema.TableColumn colvarOriginalPrice = new TableSchema.TableColumn(schema);
				colvarOriginalPrice.ColumnName = "originalPrice";
				colvarOriginalPrice.DataType = DbType.Currency;
				colvarOriginalPrice.MaxLength = 0;
				colvarOriginalPrice.AutoIncrement = false;
				colvarOriginalPrice.IsNullable = false;
				colvarOriginalPrice.IsPrimaryKey = false;
				colvarOriginalPrice.IsForeignKey = false;
				colvarOriginalPrice.IsReadOnly = false;
				colvarOriginalPrice.DefaultSetting = @"";
				colvarOriginalPrice.ForeignKeyTableName = "";
				schema.Columns.Add(colvarOriginalPrice);
				
				TableSchema.TableColumn colvarPricePaid = new TableSchema.TableColumn(schema);
				colvarPricePaid.ColumnName = "pricePaid";
				colvarPricePaid.DataType = DbType.Currency;
				colvarPricePaid.MaxLength = 0;
				colvarPricePaid.AutoIncrement = false;
				colvarPricePaid.IsNullable = false;
				colvarPricePaid.IsPrimaryKey = false;
				colvarPricePaid.IsForeignKey = false;
				colvarPricePaid.IsReadOnly = false;
				colvarPricePaid.DefaultSetting = @"";
				colvarPricePaid.ForeignKeyTableName = "";
				schema.Columns.Add(colvarPricePaid);
				
				TableSchema.TableColumn colvarAttributes = new TableSchema.TableColumn(schema);
				colvarAttributes.ColumnName = "attributes";
				colvarAttributes.DataType = DbType.String;
				colvarAttributes.MaxLength = 4000;
				colvarAttributes.AutoIncrement = false;
				colvarAttributes.IsNullable = true;
				colvarAttributes.IsPrimaryKey = false;
				colvarAttributes.IsForeignKey = false;
				colvarAttributes.IsReadOnly = false;
				colvarAttributes.DefaultSetting = @"";
				colvarAttributes.ForeignKeyTableName = "";
				schema.Columns.Add(colvarAttributes);
				
				TableSchema.TableColumn colvarDownloadURL = new TableSchema.TableColumn(schema);
				colvarDownloadURL.ColumnName = "downloadURL";
				colvarDownloadURL.DataType = DbType.String;
				colvarDownloadURL.MaxLength = 250;
				colvarDownloadURL.AutoIncrement = false;
				colvarDownloadURL.IsNullable = true;
				colvarDownloadURL.IsPrimaryKey = false;
				colvarDownloadURL.IsForeignKey = false;
				colvarDownloadURL.IsReadOnly = false;
				colvarDownloadURL.DefaultSetting = @"";
				colvarDownloadURL.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDownloadURL);
				
				TableSchema.TableColumn colvarIsShipped = new TableSchema.TableColumn(schema);
				colvarIsShipped.ColumnName = "isShipped";
				colvarIsShipped.DataType = DbType.Boolean;
				colvarIsShipped.MaxLength = 0;
				colvarIsShipped.AutoIncrement = false;
				colvarIsShipped.IsNullable = false;
				colvarIsShipped.IsPrimaryKey = false;
				colvarIsShipped.IsForeignKey = false;
				colvarIsShipped.IsReadOnly = false;
				
						colvarIsShipped.DefaultSetting = @"((0))";
				colvarIsShipped.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsShipped);
				
				TableSchema.TableColumn colvarShipDate = new TableSchema.TableColumn(schema);
				colvarShipDate.ColumnName = "shipDate";
				colvarShipDate.DataType = DbType.DateTime;
				colvarShipDate.MaxLength = 0;
				colvarShipDate.AutoIncrement = false;
				colvarShipDate.IsNullable = true;
				colvarShipDate.IsPrimaryKey = false;
				colvarShipDate.IsForeignKey = false;
				colvarShipDate.IsReadOnly = false;
				colvarShipDate.DefaultSetting = @"";
				colvarShipDate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShipDate);
				
				TableSchema.TableColumn colvarShippingEstimate = new TableSchema.TableColumn(schema);
				colvarShippingEstimate.ColumnName = "shippingEstimate";
				colvarShippingEstimate.DataType = DbType.String;
				colvarShippingEstimate.MaxLength = 150;
				colvarShippingEstimate.AutoIncrement = false;
				colvarShippingEstimate.IsNullable = true;
				colvarShippingEstimate.IsPrimaryKey = false;
				colvarShippingEstimate.IsForeignKey = false;
				colvarShippingEstimate.IsReadOnly = false;
				colvarShippingEstimate.DefaultSetting = @"";
				colvarShippingEstimate.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShippingEstimate);
				
				TableSchema.TableColumn colvarShipmentReference = new TableSchema.TableColumn(schema);
				colvarShipmentReference.ColumnName = "shipmentReference";
				colvarShipmentReference.DataType = DbType.String;
				colvarShipmentReference.MaxLength = 50;
				colvarShipmentReference.AutoIncrement = false;
				colvarShipmentReference.IsNullable = true;
				colvarShipmentReference.IsPrimaryKey = false;
				colvarShipmentReference.IsForeignKey = false;
				colvarShipmentReference.IsReadOnly = false;
				colvarShipmentReference.DefaultSetting = @"";
				colvarShipmentReference.ForeignKeyTableName = "";
				schema.Columns.Add(colvarShipmentReference);
				
				TableSchema.TableColumn colvarRating = new TableSchema.TableColumn(schema);
				colvarRating.ColumnName = "rating";
				colvarRating.DataType = DbType.Currency;
				colvarRating.MaxLength = 0;
				colvarRating.AutoIncrement = false;
				colvarRating.IsNullable = false;
				colvarRating.IsPrimaryKey = false;
				colvarRating.IsForeignKey = false;
				colvarRating.IsReadOnly = false;
				
						colvarRating.DefaultSetting = @"((4))";
				colvarRating.ForeignKeyTableName = "";
				schema.Columns.Add(colvarRating);
				
				TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
				colvarCreatedOn.ColumnName = "createdOn";
				colvarCreatedOn.DataType = DbType.DateTime;
				colvarCreatedOn.MaxLength = 0;
				colvarCreatedOn.AutoIncrement = false;
				colvarCreatedOn.IsNullable = true;
				colvarCreatedOn.IsPrimaryKey = false;
				colvarCreatedOn.IsForeignKey = false;
				colvarCreatedOn.IsReadOnly = false;
				
						colvarCreatedOn.DefaultSetting = @"(getdate())";
				colvarCreatedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedOn);
				
				TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
				colvarCreatedBy.ColumnName = "createdBy";
				colvarCreatedBy.DataType = DbType.String;
				colvarCreatedBy.MaxLength = 50;
				colvarCreatedBy.AutoIncrement = false;
				colvarCreatedBy.IsNullable = true;
				colvarCreatedBy.IsPrimaryKey = false;
				colvarCreatedBy.IsForeignKey = false;
				colvarCreatedBy.IsReadOnly = false;
				colvarCreatedBy.DefaultSetting = @"";
				colvarCreatedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarCreatedBy);
				
				TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
				colvarModifiedOn.ColumnName = "modifiedOn";
				colvarModifiedOn.DataType = DbType.DateTime;
				colvarModifiedOn.MaxLength = 0;
				colvarModifiedOn.AutoIncrement = false;
				colvarModifiedOn.IsNullable = true;
				colvarModifiedOn.IsPrimaryKey = false;
				colvarModifiedOn.IsForeignKey = false;
				colvarModifiedOn.IsReadOnly = false;
				
						colvarModifiedOn.DefaultSetting = @"(getdate())";
				colvarModifiedOn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedOn);
				
				TableSchema.TableColumn colvarModifiedBy = new TableSchema.TableColumn(schema);
				colvarModifiedBy.ColumnName = "modifiedBy";
				colvarModifiedBy.DataType = DbType.String;
				colvarModifiedBy.MaxLength = 50;
				colvarModifiedBy.AutoIncrement = false;
				colvarModifiedBy.IsNullable = true;
				colvarModifiedBy.IsPrimaryKey = false;
				colvarModifiedBy.IsForeignKey = false;
				colvarModifiedBy.IsReadOnly = false;
				colvarModifiedBy.DefaultSetting = @"";
				colvarModifiedBy.ForeignKeyTableName = "";
				schema.Columns.Add(colvarModifiedBy);
				
				TableSchema.TableColumn colvarIsLastAdded = new TableSchema.TableColumn(schema);
				colvarIsLastAdded.ColumnName = "isLastAdded";
				colvarIsLastAdded.DataType = DbType.Boolean;
				colvarIsLastAdded.MaxLength = 0;
				colvarIsLastAdded.AutoIncrement = false;
				colvarIsLastAdded.IsNullable = false;
				colvarIsLastAdded.IsPrimaryKey = false;
				colvarIsLastAdded.IsForeignKey = false;
				colvarIsLastAdded.IsReadOnly = false;
				
						colvarIsLastAdded.DefaultSetting = @"((0))";
				colvarIsLastAdded.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIsLastAdded);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["dashCommerce"].AddSchema("CSK_Store_OrderItem",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("OrderItemID")]
		public int OrderItemID 
		{
			get { return GetColumnValue<int>(Columns.OrderItemID); }

			set { SetColumnValue(Columns.OrderItemID, value); }

		}

		  
		[XmlAttribute("OrderID")]
		public int OrderID 
		{
			get { return GetColumnValue<int>(Columns.OrderID); }

			set { SetColumnValue(Columns.OrderID, value); }

		}

		  
		[XmlAttribute("ProductID")]
		public int ProductID 
		{
			get { return GetColumnValue<int>(Columns.ProductID); }

			set { SetColumnValue(Columns.ProductID, value); }

		}

		  
		[XmlAttribute("Sku")]
		public string Sku 
		{
			get { return GetColumnValue<string>(Columns.Sku); }

			set { SetColumnValue(Columns.Sku, value); }

		}

		  
		[XmlAttribute("ProductName")]
		public string ProductName 
		{
			get { return GetColumnValue<string>(Columns.ProductName); }

			set { SetColumnValue(Columns.ProductName, value); }

		}

		  
		[XmlAttribute("ImageFile")]
		public string ImageFile 
		{
			get { return GetColumnValue<string>(Columns.ImageFile); }

			set { SetColumnValue(Columns.ImageFile, value); }

		}

		  
		[XmlAttribute("ProductDescription")]
		public string ProductDescription 
		{
			get { return GetColumnValue<string>(Columns.ProductDescription); }

			set { SetColumnValue(Columns.ProductDescription, value); }

		}

		  
		[XmlAttribute("PromoCode")]
		public string PromoCode 
		{
			get { return GetColumnValue<string>(Columns.PromoCode); }

			set { SetColumnValue(Columns.PromoCode, value); }

		}

		
		
		//private decimal? propWeight;
		[XmlAttribute("Weight")]
		public decimal Weight 
		{
			get
			{
			decimal? propWeight = GetColumnValue<decimal?>(Columns.Weight);
				if (!propWeight.HasValue)
					return 0;
				return propWeight.Value;
			}

		   set { SetColumnValue(Columns.Weight, value); }

		}

		
		[XmlIgnore]
		public bool WeightHasValue
		{
			get { return GetColumnValue<decimal?>("weight") != null; }

			set
			{
				decimal? propWeight = GetColumnValue<decimal?>(Columns.Weight);
				if (!value)
					SetColumnValue(Columns.Weight, null);
				else if (value && !propWeight.HasValue)
					SetColumnValue(Columns.Weight, 0);
		   }

		}

		
		  
		[XmlAttribute("Dimensions")]
		public string Dimensions 
		{
			get { return GetColumnValue<string>(Columns.Dimensions); }

			set { SetColumnValue(Columns.Dimensions, value); }

		}

		  
		[XmlAttribute("Length")]
		public decimal Length 
		{
			get { return GetColumnValue<decimal>(Columns.Length); }

			set { SetColumnValue(Columns.Length, value); }

		}

		  
		[XmlAttribute("Height")]
		public decimal Height 
		{
			get { return GetColumnValue<decimal>(Columns.Height); }

			set { SetColumnValue(Columns.Height, value); }

		}

		  
		[XmlAttribute("Width")]
		public decimal Width 
		{
			get { return GetColumnValue<decimal>(Columns.Width); }

			set { SetColumnValue(Columns.Width, value); }

		}

		  
		[XmlAttribute("DimensionUnit")]
		public string DimensionUnit 
		{
			get { return GetColumnValue<string>(Columns.DimensionUnit); }

			set { SetColumnValue(Columns.DimensionUnit, value); }

		}

		  
		[XmlAttribute("Quantity")]
		public int Quantity 
		{
			get { return GetColumnValue<int>(Columns.Quantity); }

			set { SetColumnValue(Columns.Quantity, value); }

		}

		  
		[XmlAttribute("OriginalPrice")]
		public decimal OriginalPrice 
		{
			get { return GetColumnValue<decimal>(Columns.OriginalPrice); }

			set { SetColumnValue(Columns.OriginalPrice, value); }

		}

		  
		[XmlAttribute("PricePaid")]
		public decimal PricePaid 
		{
			get { return GetColumnValue<decimal>(Columns.PricePaid); }

			set { SetColumnValue(Columns.PricePaid, value); }

		}

		  
		[XmlAttribute("Attributes")]
		public string Attributes 
		{
			get { return GetColumnValue<string>(Columns.Attributes); }

			set { SetColumnValue(Columns.Attributes, value); }

		}

		  
		[XmlAttribute("DownloadURL")]
		public string DownloadURL 
		{
			get { return GetColumnValue<string>(Columns.DownloadURL); }

			set { SetColumnValue(Columns.DownloadURL, value); }

		}

		  
		[XmlAttribute("IsShipped")]
		public bool IsShipped 
		{
			get { return GetColumnValue<bool>(Columns.IsShipped); }

			set { SetColumnValue(Columns.IsShipped, value); }

		}

		
		
		//private DateTime? propShipDate;
		[XmlAttribute("ShipDate")]
		public DateTime ShipDate 
		{
			get
			{
			DateTime? propShipDate = GetColumnValue<DateTime?>(Columns.ShipDate);
				if (!propShipDate.HasValue)
					return new DateTime(1900,01, 01);
				return propShipDate.Value;
			}

		   set { SetColumnValue(Columns.ShipDate, value); }

		}

		
		[XmlIgnore]
		public bool ShipDateHasValue
		{
			get { return GetColumnValue<DateTime?>("shipDate") != null; }

			set
			{
				DateTime? propShipDate = GetColumnValue<DateTime?>(Columns.ShipDate);
				if (!value)
					SetColumnValue(Columns.ShipDate, null);
				else if (value && !propShipDate.HasValue)
					SetColumnValue(Columns.ShipDate, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("ShippingEstimate")]
		public string ShippingEstimate 
		{
			get { return GetColumnValue<string>(Columns.ShippingEstimate); }

			set { SetColumnValue(Columns.ShippingEstimate, value); }

		}

		  
		[XmlAttribute("ShipmentReference")]
		public string ShipmentReference 
		{
			get { return GetColumnValue<string>(Columns.ShipmentReference); }

			set { SetColumnValue(Columns.ShipmentReference, value); }

		}

		  
		[XmlAttribute("Rating")]
		public decimal Rating 
		{
			get { return GetColumnValue<decimal>(Columns.Rating); }

			set { SetColumnValue(Columns.Rating, value); }

		}

		
		
		//private DateTime? propCreatedOn;
		[XmlAttribute("CreatedOn")]
		public DateTime CreatedOn 
		{
			get
			{
			DateTime? propCreatedOn = GetColumnValue<DateTime?>(Columns.CreatedOn);
				if (!propCreatedOn.HasValue)
					return new DateTime(1900,01, 01);
				return propCreatedOn.Value;
			}

		   set { SetColumnValue(Columns.CreatedOn, value); }

		}

		
		[XmlIgnore]
		public bool CreatedOnHasValue
		{
			get { return GetColumnValue<DateTime?>("createdOn") != null; }

			set
			{
				DateTime? propCreatedOn = GetColumnValue<DateTime?>(Columns.CreatedOn);
				if (!value)
					SetColumnValue(Columns.CreatedOn, null);
				else if (value && !propCreatedOn.HasValue)
					SetColumnValue(Columns.CreatedOn, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("CreatedBy")]
		public string CreatedBy 
		{
			get { return GetColumnValue<string>(Columns.CreatedBy); }

			set { SetColumnValue(Columns.CreatedBy, value); }

		}

		
		
		//private DateTime? propModifiedOn;
		[XmlAttribute("ModifiedOn")]
		public DateTime ModifiedOn 
		{
			get
			{
			DateTime? propModifiedOn = GetColumnValue<DateTime?>(Columns.ModifiedOn);
				if (!propModifiedOn.HasValue)
					return new DateTime(1900,01, 01);
				return propModifiedOn.Value;
			}

		   set { SetColumnValue(Columns.ModifiedOn, value); }

		}

		
		[XmlIgnore]
		public bool ModifiedOnHasValue
		{
			get { return GetColumnValue<DateTime?>("modifiedOn") != null; }

			set
			{
				DateTime? propModifiedOn = GetColumnValue<DateTime?>(Columns.ModifiedOn);
				if (!value)
					SetColumnValue(Columns.ModifiedOn, null);
				else if (value && !propModifiedOn.HasValue)
					SetColumnValue(Columns.ModifiedOn, new DateTime(1900,01, 01));
		   }

		}

		
		  
		[XmlAttribute("ModifiedBy")]
		public string ModifiedBy 
		{
			get { return GetColumnValue<string>(Columns.ModifiedBy); }

			set { SetColumnValue(Columns.ModifiedBy, value); }

		}

		  
		[XmlAttribute("IsLastAdded")]
		public bool IsLastAdded 
		{
			get { return GetColumnValue<bool>(Columns.IsLastAdded); }

			set { SetColumnValue(Columns.IsLastAdded, value); }

		}

		
		#endregion
		
		
			
		
		#region ForeignKey Properties
		
		/// <summary>
		/// Returns a Order ActiveRecord object related to this OrderItem
		/// 
		/// </summary>
		public Commerce.Common.Order Order
		{
			get { return Commerce.Common.Order.FetchByID(this.OrderID); }

			set { SetColumnValue("orderID", value.OrderID); }

		}

		
		
		#endregion
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(int varOrderID,int varProductID,string varSku,string varProductName,string varImageFile,string varProductDescription,string varPromoCode,decimal varWeight,string varDimensions,decimal varLength,decimal varHeight,decimal varWidth,string varDimensionUnit,int varQuantity,decimal varOriginalPrice,decimal varPricePaid,string varAttributes,string varDownloadURL,bool varIsShipped,DateTime varShipDate,string varShippingEstimate,string varShipmentReference,decimal varRating,DateTime varCreatedOn,string varCreatedBy,DateTime varModifiedOn,string varModifiedBy,bool varIsLastAdded)
		{
			OrderItem item = new OrderItem();
			
			item.OrderID = varOrderID;
			
			item.ProductID = varProductID;
			
			item.Sku = varSku;
			
			item.ProductName = varProductName;
			
			item.ImageFile = varImageFile;
			
			item.ProductDescription = varProductDescription;
			
			item.PromoCode = varPromoCode;
			
			item.Weight = varWeight;
			
			item.Dimensions = varDimensions;
			
			item.Length = varLength;
			
			item.Height = varHeight;
			
			item.Width = varWidth;
			
			item.DimensionUnit = varDimensionUnit;
			
			item.Quantity = varQuantity;
			
			item.OriginalPrice = varOriginalPrice;
			
			item.PricePaid = varPricePaid;
			
			item.Attributes = varAttributes;
			
			item.DownloadURL = varDownloadURL;
			
			item.IsShipped = varIsShipped;
			
			item.ShipDate = varShipDate;
			
			item.ShippingEstimate = varShippingEstimate;
			
			item.ShipmentReference = varShipmentReference;
			
			item.Rating = varRating;
			
			item.CreatedOn = varCreatedOn;
			
			item.CreatedBy = varCreatedBy;
			
			item.ModifiedOn = varModifiedOn;
			
			item.ModifiedBy = varModifiedBy;
			
			item.IsLastAdded = varIsLastAdded;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(int varOrderItemID,int varOrderID,int varProductID,string varSku,string varProductName,string varImageFile,string varProductDescription,string varPromoCode,decimal varWeight,string varDimensions,decimal varLength,decimal varHeight,decimal varWidth,string varDimensionUnit,int varQuantity,decimal varOriginalPrice,decimal varPricePaid,string varAttributes,string varDownloadURL,bool varIsShipped,DateTime varShipDate,string varShippingEstimate,string varShipmentReference,decimal varRating,DateTime varCreatedOn,string varCreatedBy,DateTime varModifiedOn,string varModifiedBy,bool varIsLastAdded)
		{
			OrderItem item = new OrderItem();
			
				item.OrderItemID = varOrderItemID;
			
				item.OrderID = varOrderID;
			
				item.ProductID = varProductID;
			
				item.Sku = varSku;
			
				item.ProductName = varProductName;
			
				item.ImageFile = varImageFile;
			
				item.ProductDescription = varProductDescription;
			
				item.PromoCode = varPromoCode;
			
				item.Weight = varWeight;
			
				item.Dimensions = varDimensions;
			
				item.Length = varLength;
			
				item.Height = varHeight;
			
				item.Width = varWidth;
			
				item.DimensionUnit = varDimensionUnit;
			
				item.Quantity = varQuantity;
			
				item.OriginalPrice = varOriginalPrice;
			
				item.PricePaid = varPricePaid;
			
				item.Attributes = varAttributes;
			
				item.DownloadURL = varDownloadURL;
			
				item.IsShipped = varIsShipped;
			
				item.ShipDate = varShipDate;
			
				item.ShippingEstimate = varShippingEstimate;
			
				item.ShipmentReference = varShipmentReference;
			
				item.Rating = varRating;
			
				item.CreatedOn = varCreatedOn;
			
				item.CreatedBy = varCreatedBy;
			
				item.ModifiedOn = varModifiedOn;
			
				item.ModifiedBy = varModifiedBy;
			
				item.IsLastAdded = varIsLastAdded;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn OrderItemIDColumn
        {
            get { return Schema.Columns[0]; }

        }

        
        
        
        public static TableSchema.TableColumn OrderIDColumn
        {
            get { return Schema.Columns[1]; }

        }

        
        
        
        public static TableSchema.TableColumn ProductIDColumn
        {
            get { return Schema.Columns[2]; }

        }

        
        
        
        public static TableSchema.TableColumn SkuColumn
        {
            get { return Schema.Columns[3]; }

        }

        
        
        
        public static TableSchema.TableColumn ProductNameColumn
        {
            get { return Schema.Columns[4]; }

        }

        
        
        
        public static TableSchema.TableColumn ImageFileColumn
        {
            get { return Schema.Columns[5]; }

        }

        
        
        
        public static TableSchema.TableColumn ProductDescriptionColumn
        {
            get { return Schema.Columns[6]; }

        }

        
        
        
        public static TableSchema.TableColumn PromoCodeColumn
        {
            get { return Schema.Columns[7]; }

        }

        
        
        
        public static TableSchema.TableColumn WeightColumn
        {
            get { return Schema.Columns[8]; }

        }

        
        
        
        public static TableSchema.TableColumn DimensionsColumn
        {
            get { return Schema.Columns[9]; }

        }

        
        
        
        public static TableSchema.TableColumn LengthColumn
        {
            get { return Schema.Columns[10]; }

        }

        
        
        
        public static TableSchema.TableColumn HeightColumn
        {
            get { return Schema.Columns[11]; }

        }

        
        
        
        public static TableSchema.TableColumn WidthColumn
        {
            get { return Schema.Columns[12]; }

        }

        
        
        
        public static TableSchema.TableColumn DimensionUnitColumn
        {
            get { return Schema.Columns[13]; }

        }

        
        
        
        public static TableSchema.TableColumn QuantityColumn
        {
            get { return Schema.Columns[14]; }

        }

        
        
        
        public static TableSchema.TableColumn OriginalPriceColumn
        {
            get { return Schema.Columns[15]; }

        }

        
        
        
        public static TableSchema.TableColumn PricePaidColumn
        {
            get { return Schema.Columns[16]; }

        }

        
        
        
        public static TableSchema.TableColumn AttributesColumn
        {
            get { return Schema.Columns[17]; }

        }

        
        
        
        public static TableSchema.TableColumn DownloadURLColumn
        {
            get { return Schema.Columns[18]; }

        }

        
        
        
        public static TableSchema.TableColumn IsShippedColumn
        {
            get { return Schema.Columns[19]; }

        }

        
        
        
        public static TableSchema.TableColumn ShipDateColumn
        {
            get { return Schema.Columns[20]; }

        }

        
        
        
        public static TableSchema.TableColumn ShippingEstimateColumn
        {
            get { return Schema.Columns[21]; }

        }

        
        
        
        public static TableSchema.TableColumn ShipmentReferenceColumn
        {
            get { return Schema.Columns[22]; }

        }

        
        
        
        public static TableSchema.TableColumn RatingColumn
        {
            get { return Schema.Columns[23]; }

        }

        
        
        
        public static TableSchema.TableColumn CreatedOnColumn
        {
            get { return Schema.Columns[24]; }

        }

        
        
        
        public static TableSchema.TableColumn CreatedByColumn
        {
            get { return Schema.Columns[25]; }

        }

        
        
        
        public static TableSchema.TableColumn ModifiedOnColumn
        {
            get { return Schema.Columns[26]; }

        }

        
        
        
        public static TableSchema.TableColumn ModifiedByColumn
        {
            get { return Schema.Columns[27]; }

        }

        
        
        
        public static TableSchema.TableColumn IsLastAddedColumn
        {
            get { return Schema.Columns[28]; }

        }

        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string OrderItemID = @"orderItemID";
			 public static string OrderID = @"orderID";
			 public static string ProductID = @"productID";
			 public static string Sku = @"sku";
			 public static string ProductName = @"productName";
			 public static string ImageFile = @"imageFile";
			 public static string ProductDescription = @"productDescription";
			 public static string PromoCode = @"promoCode";
			 public static string Weight = @"weight";
			 public static string Dimensions = @"dimensions";
			 public static string Length = @"length";
			 public static string Height = @"height";
			 public static string Width = @"width";
			 public static string DimensionUnit = @"dimensionUnit";
			 public static string Quantity = @"quantity";
			 public static string OriginalPrice = @"originalPrice";
			 public static string PricePaid = @"pricePaid";
			 public static string Attributes = @"attributes";
			 public static string DownloadURL = @"downloadURL";
			 public static string IsShipped = @"isShipped";
			 public static string ShipDate = @"shipDate";
			 public static string ShippingEstimate = @"shippingEstimate";
			 public static string ShipmentReference = @"shipmentReference";
			 public static string Rating = @"rating";
			 public static string CreatedOn = @"createdOn";
			 public static string CreatedBy = @"createdBy";
			 public static string ModifiedOn = @"modifiedOn";
			 public static string ModifiedBy = @"modifiedBy";
			 public static string IsLastAdded = @"isLastAdded";
						
		}

		#endregion
		
		
		
	}

}

